/*
 * Created by JFormDesigner on Sun Jun 30 09:43:50 HKT 2024
 */

package com.hongyan.view;

import java.awt.event.*;
import com.hongyan.base.BaseJpanel;
import com.hongyan.main.SwingMainFrame;

import java.awt.*;
import javax.swing.*;

/**
 * @author hongyan
 */
public class SwingRegisterPanel extends BaseJpanel {

    public SwingRegisterPanel(SwingMainFrame swingMainFrame) {
        super(swingMainFrame);
    }


    private void regisger(ActionEvent e) {
        // TODO add your code here
    }

    private void toLogin(ActionEvent e) {
        // TODO add your code here
        getSwingMainFrame().replacePanel(new SwingLoginPanel(getSwingMainFrame()));
    }

    private void login(ActionEvent e) {
        // TODO add your code here
    }



    @Override
    public void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        label1 = new JLabel();
        label2 = new JLabel();
        textField1 = new JTextField();
        label3 = new JLabel();
        textField2 = new JTextField();
        label4 = new JLabel();
        sex = new JComboBox();
        button1 = new JButton();
        button2 = new JButton();
        label5 = new JLabel();
        type = new JComboBox();

        //======== this ========
        setLayout(null);

        //---- label1 ----
        label1.setText("\u6ce8\u518c");
        label1.setFont(new Font("\u9ed1\u4f53", Font.PLAIN, 20));
        add(label1);
        label1.setBounds(new Rectangle(new Point(225, 30), label1.getPreferredSize()));

        //---- label2 ----
        label2.setText("\u7528\u6237\u540d\uff1a");
        add(label2);
        label2.setBounds(130, 80, 52, 17);
        add(textField1);
        textField1.setBounds(200, 75, 140, 30);

        //---- label3 ----
        label3.setText("\u5bc6\u7801\uff1a");
        add(label3);
        label3.setBounds(130, 120, 52, 17);
        add(textField2);
        textField2.setBounds(200, 115, 140, 30);

        //---- label4 ----
        label4.setText("\u6027\u522b");
        add(label4);
        label4.setBounds(130, 160, 52, 17);
        add(sex);
        sex.setBounds(200, 155, 140, 30);

        //---- button1 ----
        button1.setText("\u6ce8\u518c");
        button1.addActionListener(e -> login(e));
        add(button1);
        button1.setBounds(160, 250, 103, 45);

        //---- button2 ----
        button2.setText("\u53bb\u767b\u5f55");
        button2.setFont(new Font("\u9ed1\u4f53", Font.PLAIN, 10));
        button2.addActionListener(e -> {
			login(e);
			regisger(e);
			toLogin(e);
			toLogin(e);
		});
        add(button2);
        button2.setBounds(280, 270, 60, 25);

        //---- label5 ----
        label5.setText("\u7c7b\u578b\uff1a");
        add(label5);
        label5.setBounds(130, 200, 52, 17);
        add(type);
        type.setBounds(200, 195, 140, 30);

        {
            // compute preferred size
            Dimension preferredSize = new Dimension();
            for(int i = 0; i < getComponentCount(); i++) {
                Rectangle bounds = getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            setMinimumSize(preferredSize);
            setPreferredSize(preferredSize);
        }
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    @Override
    public void initData() {


    }

    @Override
    public void initListen() {

    }

    @Override
    public int getJpanelHeight() {
        return 425;
    }

    @Override
    public int getJpanelWidth() {
        return 500;
    }

    @Override
    public String title() {
        return "注册";
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    private JLabel label1;
    private JLabel label2;
    private JTextField textField1;
    private JLabel label3;
    private JTextField textField2;
    private JLabel label4;
    private JComboBox sex;
    private JButton button1;
    private JButton button2;
    private JLabel label5;
    private JComboBox type;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
